<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			#box1
			{
				width: 300px;
				height: 200px;
				border: 1px solid saddlebrown;
			}
			#box2
			{
				width: 300px;
				border: 1px solid saddlebrown;
			}
		</style>
		<script type="text/javascript">
			window.onload=function() 
			{
				var box1=document.getElementById("box1");
			box1.onmousemove=function(event)  //当事件的响应函数被处罚时，浏览器每次都会将一个事件对象作为实参传递进响应函数
			{                               //在事件对象中封装了当前事件相关的一切信息，比如：鼠标的坐标 键盘哪个位置被按下 鼠标滚轮滚动的方向
				if(!event)
				{
					event=window.event;
				}
				//event=event||window.event;  //ie8及以下就得用window.event
				var x= event.clientX;   //可以获取鼠标指针的水平坐标
				var y=event.clientY;
				 var box2=document.getElementById("box2");
				 box2.innerHTML="x="+x+",y="+y;
				
			}
			}
			
		</script>
	</head>
	<body>
		<div id="box1"></div>
		<div id="box2"></div>
	</body>
</html>